package com.varian.tool.model;

import com.baomidou.mybatisplus.annotation.EnumValue;
import com.fasterxml.jackson.annotation.JsonValue;
import com.varian.tool.Func;
import com.varian.tool.enums.BaseEnum;
import lombok.Getter;
import lombok.RequiredArgsConstructor;

/**
 * @author ben
 * @since 2024/12/11
 */
@Getter
@RequiredArgsConstructor
public enum ExecuteType implements BaseEnum<ExecuteType> {
    // 立即执行
    IMMEDIATE(0, TaskStatus.EXECUTING),
    // 计划执行
    SCHEDULED(1, TaskStatus.NOT_EXECUTED);

    @EnumValue
    @JsonValue
    final Integer value;
    final TaskStatus initStatus;

    @Override
    public ExecuteType convert(Integer value) {
        return Func.findBaseEnumByValue(values(), value);
    }
}